package com.wxyzz.satserver.follow.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxyzz.common.core.common.PageParam;
import com.wxyzz.common.core.common.R;
import com.wxyzz.satserver.follow.service.FollowService;
import com.wxyzz.satserver.follow.vo.FanInfoVO;
import com.wxyzz.satserver.follow.vo.FollowInfoVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/followed")
@Api(tags ="关注api")
@CrossOrigin
public class FollowController {


    @Resource
    private FollowService followService;

    /**
     *  进行关注和取消关注
     * @param beFocusedId
     * @return R
     */
    @PostMapping("/follow")
    @ApiOperation(value = "关注和取消关注")
    public R follow(Integer beFocusedId) {

        followService.followUser(beFocusedId);
        return R.ok();
    }

    /**
     *  获取当前用户的粉丝数
     * @return
     */
    @GetMapping("/getFanCount")
    @ApiOperation(value = "查询当前这个用户被多少人关注")
    public R getFanCount () {
        int i = followService.beFocusedCount();
        return R.ok(i);
    }

    /**
     * 获取粉丝的信息
     * @param param
     * @return
     */
    @GetMapping("/getFanInfo")
    @ApiOperation(value = "分页查询关注当前用户的人的信息")
    public R getFanInfo (PageParam param) {
        Page<FanInfoVO> fanInfo = followService.getFanInfo(param);
        return R.ok(fanInfo);
    }

    /**
     *  获取当前用户的关注数
     * @return
     */
    @GetMapping("/getFollowCount")
    @ApiOperation(value = "查询当前用户的关注数")
    public R getFollowCount () {
        int i = followService.followCount();
        return R.ok(i);
    }
    /**
     * 获取 当前用户的关注信息
     * @param param
     * @return
     */
    @GetMapping("/getFollowInfo")
    @ApiOperation(value = "查询当前用户的关注用户的详细信息")
    public R getFollowInfo (PageParam param) {
        Page<FollowInfoVO> followInfo = followService.getFollowInfo(param);
        return R.ok(followInfo);
    }
}
